package com.wyix.coffee.service;

import com.wyix.coffee.bean.CoffeeMaker;

/**
 * @author wangdx
 * @since 2025/8/6
 */
public class BaristaSetterInjection {
    private CoffeeMaker coffeeMaker; // 可变依赖

    // Setter注入（可选依赖）
    public void setCoffeeMaker(CoffeeMaker coffeeMaker) {
        this.coffeeMaker = coffeeMaker;
    }

    public String serveCoffee() {
        if (coffeeMaker == null) {
            throw new IllegalStateException("未设置咖啡机！");
        }
        return "咖啡师（Setter注入）服务：" + coffeeMaker.makeCoffee();
    }
}